#include "torrentpeerdata.h"

TorrentPeerData::TorrentPeerData(QHostAddress _ip, quint16 _port,
                                 QString _peerId, int piecesNumber ) :
                    ipAddress(_ip), port(_port), peerId(_peerId),
                    amInterested(false), amChoking(true),
                    peerInterested(false), peerChoking(true),
                    piecesOwned(piecesNumber)
{

}

bool TorrentPeerData::hasPiece(int pieceIndex)
{
    bool peerHasPiece = piecesOwned.at(pieceIndex);
    qDebug() << "peer " << ipAddress.toString() << " " <<
            (peerHasPiece ? "has" : "doesn't have") << "piece "
            << QString::number(pieceIndex);
    return peerHasPiece;
}
